// 导入二次封装axios
import App from "@/utils/axios.ts";

// 统一管理接口
enum API {
  LOGIN = "/login",           // 登录接口
  CAPTCHA = "/api/captcha",       // 验证码接口
  LOGOUT = "/logout",         // 登出接口
  GET_USER_INFO = "/getUserInfo", // 获取用户信息
}

/**
 * 用户登录
 * @param params 登录参数 {loginName: string, password: string, securityCode?: string, codeKey?: string}
 * @returns Promise
 */
export const login = (params: any) => {
  return App.post(API.LOGIN, params);
};

/**
 * 获取验证码
 * @returns Promise
 */
export const getCaptcha = () => {
  return App.get(API.CAPTCHA);
};

/**
 * 退出登录
 * @returns Promise
 */
export const logout = () => {
  return App.post(API.LOGOUT);
};

/**
 * 获取用户信息
 * @returns Promise
 */
export const getUserInfo = () => {
  return App.get(API.GET_USER_INFO);
};